<template>
	<view class="index-container">
		<view class="titleStyPOs">
			<div style="height:30rpx;"></div>
			<view :style="{height: statusBarHeight + 'px'}"></view>
			<div class="header">
				<div class="back flex-start ml-30 mr-30" @click="back">
					<image src="../../../static/icon/back.png" mode="widthFix" class="w-20 h-30"></image>
				</div>
				<u-search :placeholder="$t('请搜索')" :showAction="false" :animation="false" bgColor="#fff" v-model="keyword"
				class="searchSty" @search="goFilter" height="78"></u-search>

				<!-- <view class="">
					<view class="transport">
						<view class="transport_name">
							<city :value="paramsList.city_name" class="w-full" is_all="true"  @change="e => {
                               paramsList.city_name = e.column2.value == -1 || e.column3.value == -1 ?
                               [e.column1.label, e.column2.label.replace('全部', ''), e.column3.label.replace('全部', '')].filter(item => item).join(',') :
                                  e.column3.label;
                                    paramsList.city_id = [e.column1.value, e.column2.value, e.column3.value].join(',');
                                }">
                                    <div class="h-full flex fz26 ml-20 w-full"
                                        :class="{ 'font-bold': paramsList.city_name }"
                                        :style="{ color: paramsList.city_name ? '#333' : '#8c8c8c' }">
                                        {{ paramsList.city_name || $t('请选择') }}
                                    </div>
                                </city>
						</view>
						<u-icon v-if="paramsList.city_id" name="close" color="#8C8C8C" size="24rpx" @click="delAddress"></u-icon>
						<u-icon name="arrow-down" color="#8C8C8C" size="24rpx" class="ml-20"></u-icon>
					</view>
				</view> -->
		</div>
		<tipSl :text="$t('【重要提示】交易前请核实服务方资质与评价！警惕超低价/夸大宣传，遇欺诈速联系平台举报，我们全力配合保障您的权益！')" style="margin: 0;background-color: transparent;padding-bottom: 0;"></tipSl>
		</view>
		<view :style="`height: calc(${statusBarHeight}px + 230rpx)`"></view>
		<view class="rounded-26" style="">
			<view class="" v-for="(item, index) in liveList" @click="goDetail(item)">
				<view class="flex-start infoBoxSty">
					<!-- aspectFill -->
					<image  :src="getImageUrl((item.images && item.images.length > 0 && item.images[0])) " mode="aspectFill" class="w-170 h-170 mt-24 ml-24 mb-24" style="border-radius: 16rpx;"></image>
					<view class="flex-1">
						<p class="text-010 fz28 pt-40 ml-24 font-bold">{{item[plang('title')]}}</p>
						<p class="text-888 fz20 mt-18 ml-25" style="max-height: 90rpx;white-space: wrap;overflow: hidden;text-overflow: ellipsis;line-height:30rpx">
							{{item[plang('content')]}}
						</p>
						<view class="between ml-15 mr-15 pb-15 mt-10 infoBg">
							<!-- <view class="mt-15">
								<image src="../../../static/images/user/newUI/avtateIcon.png" mode="" class="w-35 h-35 vam"></image>
								<span class="fz18 text-888 ml-20">{{item.name}}</span>
							</view> -->
							<p  class="text-888 fz20 mt-18 ml-10">{{item.day}}</p>
							<view class="flex mr-30">
								<view class="mt-15">
									<image src="../../../static/images/user/newUI/watchIcon.png" mode="" class="w-20 h-20 vam"></image>
									<span class="fz22 text-888 ml-8">{{item.num}}</span>
								</view>
								<view class="mt-15 ml-20">
									<image src="../../../static/images/user/newUI/saveIcon.png" mode="" class="w-20 h-20 vam"></image>
									<span class="fz22 text-888 ml-8">{{item.zan}}</span>
								</view>
							</view>
						</view>
					</view>
				</view>
				<!-- <view v-if="index % 2 == 0" class="liveBoxLeft mt-15">
					<image src="../../../static/images/user/newUI/liveImg.png" mode=""></image>
					<view class="bg-white liveInfoBox">
						<p class="text-010 fz28 pt-24 ml-24 font-bold">{{item.name}}</p>
						<p class="ml-24 mr-24 mt-15 text-555 fz24 pb-24">{{item.content}}</p>
					</view>
				</view>
				<view v-else class="liveBox mt-15"> 
					<image src="../../../static/images/user/newUI/liveImg.png" mode=""></image>
					<view class="bg-white liveInfoBox">
						<p class="text-010 fz28 pt-24 ml-24 font-bold">{{item.name}}</p>
						<p class="ml-24 mr-24 mt-15 text-555 fz24 pb-24">{{item.content}}</p>
					</view>
				</view> -->
				
			</view>
		</view>
		
		<view class="releaseBox" @click="sendAdvertising">
			 <image src="../../../static/icon/releaseIcon.png" mode="" class="w-40 h-40"></image>
			 <p class="fz24 text-white mt-10">{{$t('发布')}}</p>
		</view>
			
			<div v-if="nomore" class="center text-gray-500 fz24 pt-20 pb-20">{{$t('没有更多了')}}</div>
		<view class="h-50"></view>
	</view>
</template>

<script>
	import { getExposureList, sendSaveExposure } from '@/api/basic'
	import citySelect from "./components/citySelect.vue"
	
	export default {
		components: {
			citySelect
		},
		data() {
			return {
				current: 0,
				keyword: '',
				statusBarHeight: uni.getStorageSync('statusBarHeight') || 0,
				IMAGE_URL: 'https://gluz-oss.oss-cn-beijing.aliyuncs.com/',
				nomore: false,
				paramsList:{
					city_id: '',
					city_name: '',
					page: 1,
					limit: 10,
					searchKey: ''
				},
				liveList: []
			}
		},
		  created() {
			// 刷新页面
			console.log('99999')
			window.onNativeShow = this.getExposureList
		  },
		mounted() {
			this.getExposureList(true)
		},
		watch: {
			'paramsList.city_id': {
				handler(val) {
					console.log(this.paramsList.city_id)
					this.getExposureList(true)
				},
			}
		},
		methods: {
			goFilter(e) {
				this.paramsList.searchKey = e
				this.getExposureList(true)
			},
			delAddress() {
				this.paramsList.city_id = ''
				this.paramsList.city_name = ''
				this.getExposureList(true)
			},
			//下拉刷新
			onPullDownRefresh() {
				this.getExposureList(true)
			},
			//上拉加载
			onReachBottom() {
				this.paramsList.page++
				this.getExposureList()
			},
			getExposureList(init) {
				if (init) {
					this.paramsList.page = 1
					this.nomore = false;
				}
				getExposureList(this.paramsList).then(res => {
					if (this.paramsList.page == 1) {
						this.liveList = res.data.data
					} else {
						this.liveList = [...this.liveList, ...res.data.data]
					}
					//当前请求的{{$t('列表')}}{{$t('是')}}空的 那就{{$t('是')}}没有更多了
					if (res.data.data.length == 0) {
						this.nomore = true;
					}
					// 结束下拉刷新
					uni.stopPullDownRefresh()
				})
			},
			
			back() {
				uni.navigateBack()
				// uni.navigateTo({
				// 	url:'/pages/app/index',
				// 	webview: 'zWebView',
				// })
			},
			goDetail(item) {
				console.log('item--', item)
				uni.setStorageSync('exposureDetail',item)
				uni.navigateTo({
					// url: `/pages/tabbar/exposurePlatform/exposureDetail?item=${JSON.stringify(item)}`
					url: `/pages/tabbar/exposurePlatform/exposureDetail`
				})
			},
			sendAdvertising() {
				uni.navigateTo({
					url: '/pages/tabbar/exposurePlatform/sendExposure'
				})
			}
		}
	}
</script>

<style lang="scss">
	@import '@/assets/appScss.scss';
	page {
		background-color: #F6F7FB;
	}
	.index-container {
		// width: 100%;
		// height: 100%;
		// background: #F6F7FB url("/static/backcolorImg.png") no-repeat top / 100%;
		// position: relative;
		// z-index: 5;
		// position: fixed;
		// z-index: 60;
	}
	.titleStyPOs {
		background: #F6F7FB url("/static/backcolorImg.png") no-repeat top / 100%;
		position: fixed;
		width: 100%;
		z-index: 10;
		padding-bottom: 26rpx;
	}
	.infoBoxSty {
		background-color: #fff;
		margin-left: 24rpx;
		margin-right: 24rpx;
		border-bottom: 1rpx solid #F0F0F0;
	}
	.liveBoxLeft {
		float: left;
		width: 50%;
		image {
			width: 340rpx;
			height: 326rpx;
		}
		.liveInfoBox {
			width: 340rpx;
			min-height: 100rpx;
			border-radius: 0 0 18rpx 18rpx;
		}
	}
	.liveBox {
		width: 50%;
		float: right;
		image {
			width: 340rpx;
			height: 326rpx;
		}
		.liveInfoBox {
			width: 340rpx;
			min-height: 100rpx;
			border-radius: 0 0 18rpx 18rpx;
		}
	}
	
	.header {
		font-size: 34rpx;
		font-weight: bold;
		position: relative;
		display: flex;
		align-items: center;
		margin-right: 24rpx;
		.searchSty {
		
		}
	}
	.transport {
		width: 170rpx;
		height: auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		margin-top: 10rpx;
		// height: 80rpx;
		// border-radius: 20rpx;
		// background: #F6F7FB;
		// padding: 0 20rpx 0 20rpx;
	
		.transport_name {
			// width: 130rpx;
			white-space: wrap;
			// overflow: hidden;
			// text-overflow: ellipsis;
			color: #0e0e0e;
			font-size: 22rpx !important;
			line-height: 20px;
		}
	}
	.list-title {
		// width: 100%;
		display: flex;
		justify-content: flex-start;
		padding-top: 10rpx;
		padding-bottom: 20rpx;
		// flex-wrap: nowrap;
		overflow-x: scroll;
		// height: 100rpx;
	
		.commonTitle {
			height: 46rpx;
			// width: 120rpx;
			font-size: 28rpx;
			color: #535353;
			margin-left: 25rpx;
		}
	
		.active {
			font-size: 28rpx;
			color: #278AFF;
			font-weight: 600;
			border-bottom: 4rpx solid #278AFF;
		}
	}
	.priceSty {
		color: #FF7000;
		font-size: 30rpx;
		margin-left: 16rpx;
		margin-top: 20rpx;
	}
	.infoBg {
		background-image: url('../../../static/images/user/newUI/userinfoBg.png');
	}
	.releaseBox {
		width: 156rpx;
		height: 156rpx;
		border-radius: 500rpx;
		background: linear-gradient(90deg, #278AFF 0%, #66D6E2 100%);
		box-shadow: 0rpx 4rpx 13.8rpx 0rpx #DEE1EF;
		box-shadow: -2rpx -6rpx 9.9rpx 0rpx #71D0FF inset;
		box-shadow: -4rpx 5rpx 6.5rpx 0rpx #C8FBFF75 inset;
		position: fixed;
		z-index: 10;
		right: 40rpx;
		bottom: 150rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
</style>
